package com.demohomework.homeworkdemo.controller;


import com.demohomework.homeworkdemo.pojo.AssAllocation;
import com.demohomework.homeworkdemo.pojo.AssCorrect;
import com.demohomework.homeworkdemo.pojo.Assignment;
import com.demohomework.homeworkdemo.pojo.Result;
import com.demohomework.homeworkdemo.service.AssAllocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//作业分配
@RestController
@RequestMapping("/assAllocation")
public class AssAllocationController {
    @Autowired
    private AssAllocationService assAllocationService;

    //显示分配给自己的作业
    @GetMapping("/list")
    public Result<List<AssAllocation>> list(@RequestParam("stuId") int stuId, @RequestParam("assClass") int assClass) {
        List<AssAllocation> assignments = assAllocationService.list(stuId, assClass);
        return Result.success(assignments);
    }
    //新增批改作业
    @PostMapping("/add")
    public Result<String> add(AssAllocation assAllocation) {
        assAllocationService.add(assAllocation);
        return Result.success("新增成功");
    }
    //更新批改状态
    @PutMapping("/update")
    public Result update(@RequestBody @Validated(AssAllocation.Update.class)AssAllocation assAllocation) {
        assAllocationService.update(assAllocation);
        return Result.success();
    }


}
